#ifndef __PLANAR_GRID_H__
#define __PLANAR_GRID_H__

#include "grid.h"
#include "math/vector.h"

#include <boost/serialization/nvp.hpp>
#include <boost/serialization/version.hpp>

namespace Sirat {

namespace Common {

class Planar_Grid : public Grid {

public:
	Planar_Grid(const unsigned short&,const unsigned short&,const Math::Vector&,const Math::Vector&,const Math::Vector&,const Math::Vector&);
	Planar_Grid();
	Planar_Grid(const Planar_Grid& _planar_grid);
	~Planar_Grid();
	virtual Math::Vector projection_transformation(unsigned int x,unsigned int y);
	
	Planar_Grid& operator=(const Planar_Grid& _planar_grid);

	Grid* clone() { return new Planar_Grid(*this); }
	
private:
	friend class boost::serialization::access;
	template<class Archive> void serialize(Archive&, const unsigned int);   
};

template<class Archive> void Planar_Grid::serialize(Archive& ar, const unsigned int /* file_version */){
	ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Grid);
}

inline
Math::Vector Planar_Grid::projection_transformation(unsigned int _pixel_x,unsigned int _pixel_y) {
	const double px = ((2.0/width)*_pixel_x) - 1.0;
	const double py = ((2.0/height)*_pixel_y) - 1.0;
	return x*px + y*py;
}

}

}

#endif
